 #include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->push_button_01, &QPushButton::clicked, this, [=]() {
        // getInt(father, title, message, default value, min value, max value, step);
        int age = QInputDialog::getInt(this, "Get Age", "You Age Was: ", 18, 0, 150, 1);

        qDebug() << "age = " << age << endl;
    });

    connect(ui->push_button_02, &QPushButton::clicked, this, [=]() {
        // getDouble(father, title, message, default value, min value, max value, precision);
        double salary = QInputDialog::getDouble(this, "Get Salary", "You Salary Was: ", 2000, 0, 100000, 2);

        qDebug() << "salary = " << salary << endl;
    });

    connect(ui->push_button_03, &QPushButton::clicked, this, [=]() {
        QStringList fruit_list;
        fruit_list << "Apple" << "Orange" << "Banana" << "WaterMelon" << "Pear" << "Grapes";

        // getItem(father, title, message, item list, default select, enable item value);
        QString select_fruit =  QInputDialog::getItem(this, "Select You Love Fruit", "Select Fruit", fruit_list, 1, false);

        qDebug() << "Select Fruit Was:" << select_fruit << endl;

    });

    connect(ui->push_button_04, &QPushButton::clicked, this, [=]() {
        // getText(father, title, message, type, defalut value);
        QString password = QInputDialog::getText(this, "Password", "Input You Password", QLineEdit::Password, "123123");

        qDebug() << "Password Was:" << password << endl;
    });

    connect(ui->push_button_05, &QPushButton::clicked, this, [=]() {
        // getMultiLineText(father, title, message, defalut value);
        QString infomation = QInputDialog::getMultiLineText(this, "Infomation", "Input You Infomation", "Chenge This Value");

        qDebug() << "Input Infomation Was: " << infomation << endl;
    });
}

Widget::~Widget()
{
    delete ui;
}

